# File Name:
# Author:chenjiajun
# Date:2025/9/4
import time

from authlib.jose import jwt,JoseError


from flask import current_app

def create_token(uid):
    payload = {
        "user_id" : uid,
        "exp" : int(time.time()) + current_app.config['EXPIRES']
    }
    token = jwt.encode(
        {"alg": "HS256", "typ": "JWT"},
        payload,
        current_app.config['SECRET_KEY']
    ).decode('utf-8')
    return token

def decode_jwt(token):
    decoded = jwt.decode(token, current_app.config['SECRET_KEY'])
    return decoded